﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_StrategicPlanDateManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGdv();
        }
    }

    void BindGdv()
    {
        string sql = @"SELECT [Id]
                      ,[StrategicDate]
                      ,[IsDelete]
                     FROM [DS_StrategicDate]  
                     WHERE ISDELETE = 0";
        this.gdvStrategicDate.DataSource = DAL.SqlHelper.ExecuteDataset(DAL.SqlHelper.connStr, System.Data.CommandType.Text, sql).Tables[0];
        this.gdvStrategicDate.DataBind();
    }


    protected void btnDelete_Click(object sender, EventArgs e)
    {
        Button bt = (Button)sender;//获得当前控件
        TableCell cell = (TableCell)bt.Parent;//得到所处的父单元格
        GridViewRow iRow = (GridViewRow)cell.Parent;//得到所处父单元行
        int _rowIndex = iRow.RowIndex;//得到该行的索引
        int Id = Convert.ToInt32(this.gdvStrategicDate.Rows[_rowIndex].Cells[0].Text);
        string sql = "UPDATE DS_StrategicDate SET IsDelete =1 WHERE [Id] =" + Id;
        if (DAL.SqlHelper.ExecuteNonQuery(DAL.SqlHelper.connStr, System.Data.CommandType.Text, sql) > 0)
        {
            BindGdv();
        }
    }


    protected void btnModify_Click(object sender, EventArgs e)
    {
        Button bt = (Button)sender;//获得当前控件
        TableCell cell = (TableCell)bt.Parent;//得到所处的父单元格
        GridViewRow iRow = (GridViewRow)cell.Parent;//得到所处父单元行
        int _rowIndex = iRow.RowIndex;//得到该行的索引
        int Id = Convert.ToInt32(this.gdvStrategicDate.Rows[_rowIndex].Cells[0].Text);
        Response.Redirect("StrategicDateModify.aspx?Id=" + Id);
    }
}